Find the sum of
two numbers.
Input. The first line
contains the number of test cases t (1 ≤ t ≤ 100). Each of the
following t test cases
contains two integers a and b.
Output. For each test case, print the sum of a and b in
a separate line.
Sample
input |
Sample
output |
3 2 3 17 -18 5 6 |
5 -1 11 |
loop
Read the number of test cases t. Process the test cases
sequentially: read a pair of numbers and print their sum.
Read the number of test
cases t.
scanf("%d",&t);
Process t test cases sequentially.
while(t--)
{
Read the numbers a and b and print their
sum on a separate line.
scanf("%d
%d",&a,&b);
printf("%d\n",a + b);
}
Read the number of test
cases t.
scanf("%d",&t);
Process t test cases sequentially.
for(i = 0; i < t; i++)
{
Read the numbers a and b and print their
sum on a separate line.
scanf("%d
%d",&a,&b);
printf("%d\n",a + b);
}
Java
implementation
import java.util.*;
public class Main
{
public static void main(String []args)
{
Scanner con = new
Scanner(System.in);
int t = con.nextInt();
while (t-- > 0)
{
int a = con.nextInt();
int b = con.nextInt();
System.out.println(a + b);
}
con.close();
}
}
Python implementation
Read the number of test
cases tests.
tests = int(input())
Process tests test cases
sequentially.
for i in range(tests):
Read the numbers a and b and print their
sum on a separate line.
a, b = map(int,input().split())
print(a + b)